<template>
  <div class="ginsimg">
    <div class="ginsfonP">图文详情</div>
    <div>
      <img class="ginsfonPimg" v-for="(image, index) in imageList" :key="index" :src="image.description" alt="图文详情图片" />
    </div>
  </div>
</template>


<script setup>
import { ref, onMounted } from 'vue'
import axios from 'axios'
import { useRoute } from 'vue-router'

const route = useRoute()
const productId = ref(route.params.id)  // 获取商品 id

// 存储图片列表
const imageList = ref([])

// 请求图文详情的图片列表
const fetchImages = async () => {
  try {
    const response = await axios.get('http://localhost:8080/home/productesimg', {
      params: { productId: productId.value }  // 根据商品 ID 请求图文详情
    })

    if (response.data.status === 200) {
      imageList.value = response.data.data  // 假设返回的数据是图片的路径数组
    } else {
      console.error('接口返回错误', response.data.message)
    }
  } catch (error) {
    console.error('请求图文详情失败', error)
  }
}

// 在组件挂载后请求图片数据
onMounted(() => {
  fetchImages()
})
</script>



<style>
.ginsimg {
  margin: 10px 10px;
  width: 99%;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

.ginsfonP {
  margin-left: 2%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 0;
  color: black;
  font-size: 25px;
  font-weight: bold;
}

.ginsfonPimg {
  max-width: 100%;
  height: auto;
  margin-left: 31px;
  width: 67%;
}
</style>

